<?php
namespace org\crawlgenie\models;
use org\crawlgenie\models\dao\JobListingDAO;
use org\crawlgenie\application\environment\Request;
use \Logger;
use \CGException;


/**
 * Description of JobListing
 * This is the class for JobListing, 
 * meant to update the repos_jobs_intermediate table
 * 
 *  @author $Author: jinsonxu@gmail.com $:
 *  $Date: 2014-11-16 10:39:12 +0000 (Sun, 16 Nov 2014) $:
 *  $Id: JobListing.php 16 2014-11-16 10:39:12Z jinsonxu@gmail.com $:
 *  @version $Rev: 16 $:
 *  @package crawlgenie.models
 *  @subpackage dao
 */

class JobListing extends BaseModel {
       
    protected $id, $metadataID, $listingID, $postDate, $closeDate, $listingCompanyName, 
            $listingTitle, $description, $requirements, $industry, $category, $employmentType, 
            $workingHours, $shiftPattern, $minSalary, $maxSalary, $jobLevel, $minYearsExperience,
            $location, $address, $postalCode, $contactTelephone, $contactEmail, $vacancies, 
            $viewed, $applied, $lastUpdated;    

    
    
    public function __construct($id = null) {
        $this->id = $id;
        $this->lastUpdated = date('Y-m-d H:i:sO');  // set by default to the current date timestamp        
    }


    public function exists() {
        return JobListingDAO::exists($this->id, $this->metadata_id);
    }

    
    public function store() {
        JobListingDAO::store($this);
    }

    
    public function load($parsedArray = null) {
        
        if(null == $parsedArray) {
            //means that we need to load from ID if it exists.            
            if($this->id && JobListingDAO::exists($this->id, null)) {
                $parsedArray = $this->processArray(get_object_vars(JobListingDAO::load($this->id)));                
            } else {
                Logger::getLogger(__CLASS__)->info(__METHOD__ . ': Unable to load JobListing object ' . $this->id . '. Does not exist in DB yet.');
            }
        }
        
        // load from the parsedArray
        $this->address = trim($parsedArray['address']);
        $this->applied = $parsedArray['applied'];
        $this->category = trim($parsedArray['category']);
        $this->closeDate = $parsedArray['close_date'];
        $this->contactEmail = $parsedArray['contact_email'];
        $this->contactTelephone = $parsedArray['contact_telephone'];
        $this->description = trim($parsedArray['description']);
        $this->employmentType = trim($parsedArray['employment_type']);
        $this->industry = trim($parsedArray['industry']);
        $this->jobLevel = trim($parsedArray['job_level']);
        $this->listingCompanyName = trim($parsedArray['listing_company_name']);
        $this->listingID = trim($parsedArray['listing_id']);
        $this->listingTitle = trim($parsedArray['listing_title']);
        $this->location = $parsedArray['location'];
        $this->maxSalary = $parsedArray['max_salary'];
        $this->minSalary = $parsedArray['min_salary'];
        $this->metadataID = isset($this->metadataID) ? $this->metadataID : $parsedArray['metadata_id'];
        $this->minYearsExperience = $parsedArray['min_years_experience'];
        $this->postDate = $parsedArray['post_date'];
        $this->postalCode = $parsedArray['postal_code'];
        $this->requirements = trim($parsedArray['requirements']);
        $this->shiftPattern = trim($parsedArray['shift_pattern']);
        $this->vacancies = $parsedArray['vacancies'];
        $this->viewed = $parsedArray['viewed'];
        $this->workingHours = $parsedArray['working_hours'];
    }





    
    public function getId() {
        return $this->id;
    }

    public function getMetadataID() {
        return $this->metadataID;
    }

    public function getListingID() {
        return $this->listingID;
    }

    public function getPostDate() {
        return $this->postDate;
    }

    public function getCloseDate() {
        return $this->closeDate;
    }

    public function getListingCompanyName() {
        return $this->listingCompanyName;
    }

    public function getListingTitle() {
        return $this->listingTitle;
    }

    public function getDescription() {
        return $this->description;
    }

    public function getRequirements() {
        return $this->requirements;
    }

    public function getIndustry() {
        return $this->industry;
    }

    public function getCategory() {
        return $this->category;
    }

    public function getEmploymentType() {
        return $this->employmentType;
    }

    public function getWorkingHours() {
        return $this->workingHours;
    }

    public function getShiftPattern() {
        return $this->shiftPattern;
    }

    public function getMinSalary() {
        return $this->minSalary;
    }

    public function getMaxSalary() {
        return $this->maxSalary;
    }

    public function getJobLevel() {
        return $this->jobLevel;
    }

    public function getMinYearsExperience() {
        return $this->minYearsExperience;
    }

    public function getLocation() {
        return $this->location;
    }

    public function getAddress() {
        return $this->address;
    }

    public function getPostalCode() {
        return $this->postalCode;
    }

    public function getContactTelephone() {
        return $this->contactTelephone;
    }

    public function getContactEmail() {
        return $this->contactEmail;
    }

    public function getVacancies() {
        return $this->vacancies;
    }

    public function getViewed() {
        return $this->viewed;
    }

    public function getApplied() {
        return $this->applied;
    }

    public function getLastUpdated() {
        return $this->lastUpdated;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setMetadataID($metadataID) {
        $this->metadataID = $metadataID;
    }

    public function setListingID($listingID) {
        $this->listingID = $listingID;
    }

    public function setPostDate($postDate) {
        $this->postDate = $postDate;
    }

    public function setCloseDate($closeDate) {
        $this->closeDate = $closeDate;
    }

    public function setListingCompanyName($listingCompanyName) {
        $this->listingCompanyName = $listingCompanyName;
    }

    public function setListingTitle($listingTitle) {
        $this->listingTitle = $listingTitle;
    }

    public function setDescription($description) {
        $this->description = $description;
    }

    public function setRequirements($requirements) {
        $this->requirements = $requirements;
    }

    public function setIndustry($industry) {
        $this->industry = $industry;
    }

    public function setCategory($category) {
        $this->category = $category;
    }

    public function setEmploymentType($employmentType) {
        $this->employmentType = $employmentType;
    }

    public function setWorkingHours($workingHours) {
        $this->workingHours = $workingHours;
    }

    public function setShiftPattern($shiftPattern) {
        $this->shiftPattern = $shiftPattern;
    }

    public function setMinSalary($minSalary) {
        $this->minSalary = $minSalary;
    }

    public function setMaxSalary($maxSalary) {
        $this->maxSalary = $maxSalary;
    }

    public function setJobLevel($jobLevel) {
        $this->jobLevel = $jobLevel;
    }

    public function setMinYearsExperience($minYearsExperience) {
        $this->minYearsExperience = $minYearsExperience;
    }

    public function setLocation($location) {
        $this->location = $location;
    }

    public function setAddress($address) {
        $this->address = $address;
    }

    public function setPostalCode($postalCode) {
        $this->postalCode = $postalCode;
    }

    public function setContactTelephone($contactTelephone) {
        $this->contactTelephone = $contactTelephone;
    }

    public function setContactEmail($contactEmail) {
        $this->contactEmail = $contactEmail;
    }

    public function setVacancies($vacancies) {
        $this->vacancies = $vacancies;
    }

    public function setViewed($viewed) {
        $this->viewed = $viewed;
    }

    public function setApplied($applied) {
        $this->applied = $applied;
    }

    public function setLastUpdated($lastUpdated) {
        $this->lastUpdated = $lastUpdated;
    }

    
    

}
?>